//
//  ThreePixelHorizontalLineView.m
//  OntheRoadV4
//
//  Created by hz on 5/29/14.
//  Copyright (c) 2014 EricHuang. All rights reserved.
//

#import "ThreePixelHorizontalLineView.h"
#import "QWKitConfig.h"
#import "CommonCGDrawings.h"
@implementation ThreePixelHorizontalLineView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _lineColor = V4_SeparatorLineColor;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        _lineColor = V4_SeparatorLineColor;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    _lineColor = V4_SeparatorLineColor;
    self.backgroundColor = [UIColor clearColor];
}

- (void)setLineColor:(UIColor *)lineColor
{
    _lineColor = lineColor;
    [self setNeedsDisplay];
}

- (void)setIsTop:(BOOL)isTop
{
    _isTop = isTop;
    [self setNeedsDisplay];
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    if (_isTop) {
        draw3PxHorizontalStroke(context, rect.origin, rect.size.width, _lineColor.CGColor);
    } else {
        draw3PxHorizontalStroke(context, CGPointMake(rect.origin.x, rect.origin.y + 0.5f), rect.size.width, _lineColor.CGColor);
    }
}


@end
